package Eyjafjalla.action;

import Eyjafjalla.card.skill.TheEnd_Eyjafjalla;
import Eyjafjalla.patch.MelodyPatch;
import Eyjafjalla.subscriber.MelodySubscriber;
import com.megacrit.cardcrawl.actions.AbstractGameAction;
import com.megacrit.cardcrawl.actions.common.ApplyPowerAction;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.powers.DexterityPower;
import com.megacrit.cardcrawl.powers.LoseDexterityPower;
import com.megacrit.cardcrawl.powers.LoseStrengthPower;
import com.megacrit.cardcrawl.powers.StrengthPower;

import java.util.ArrayList;

public class TheEndAction extends AbstractGameAction {
    public TheEndAction(TheEnd_Eyjafjalla end){
        this.end = end;
    }

    @Override
    public void update() {

        if(end!=null&&AbstractDungeon.player.hand.size()>0){
            ArrayList<MelodyPatch.MelodyNote> notes = new ArrayList<>();
            int index = 0;
            for(AbstractCard c:AbstractDungeon.player.hand.group){
                int type = 0;
                switch (c.type){
                    case ATTACK:type=1;break;
                    case SKILL:type=2;break;
                    default:type=3;break;
                }
                MelodyPatch.MelodyNote note = new MelodyPatch.MelodyNote(end,index,type,end.getNoteString());
                notes.add(note);
                index++;
            }
            MelodyPatch.MelodySingle single = new MelodyPatch.MelodySingle(end.getNoteName(),notes,null);
            addToTop(new MelodyAction(single));
        }

        this.isDone = true;
    }

    TheEnd_Eyjafjalla end;
}
